package chapter10;

import java.io.*;

/**
 * 使用自动关闭资源的try语句
 * 可自动关闭的资源必须实现AutoCloseAble或者Closeable接口
 */
public class AutoCloseTest {
    public static void main(String[] args) throws IOException {
        try(
                BufferedReader br = new BufferedReader(new FileReader("src/chapter10/AutoCloseTest.java"));
            PrintStream ps = new PrintStream(new FileOutputStream("a.txt")))
        {
            System.out.println(br.readLine());
            ps.println("庄生晓梦迷蝴蝶");
        }


    }
}
